function printMaxPSNR(net_names, results)

if ischar(net_names)
    net_names = {net_names};
end

net_num = length(net_names);
ImgSets = fieldnames(results);
set_num = length(ImgSets);

% cnt = 0;
% maxIdx = zeros(net_num, set_num*2);
% for set_i = 1 : set_num
%     result = results.(ImgSets{set_i});
%     if isempty(result{1})
%         set_num = set_i - 1;
%         maxIdx = maxIdx(:, 1 : set_num*2);
%         break;
%     end
%     for j = 1 : 2
%         [~, maxIdxList] = cellfun(@(x)max(mean(x)), result(:, j), 'UniformOutput', false);
%         cnt = cnt + 1;  maxIdx(:, cnt) = [maxIdxList{:}];
%     end
% end

%%
[~, BestIndex] = sranaly.getBestModelIters(results);

%%
% maxQualityList = cell(size(maxIdx, 1), set_num);
maxQualityList = cell(length(BestIndex), set_num);
for set_i = 1 : set_num
    ImgSet = ImgSets{set_i};
    result = results.(ImgSet);
    
    meanPSNRList = cellfun(@mean, result(:, 1), 'UniformOutput', false);
    meanSSIMList = cellfun(@mean, result(:, 2), 'UniformOutput', false);
    
    for net_i = 1 : net_num
        if srdata.isBigDataSet(ImgSet)
            maxQualityList{net_i, set_i} = [meanPSNRList{net_i}; meanSSIMList{net_i}];
            continue
        end
        
        % max_idx = unique(maxIdx(net_i, :));
        max_idx = BestIndex{net_i};
        try
        maxQualityList{net_i, set_i} = [meanPSNRList{net_i}(max_idx); meanSSIMList{net_i}(max_idx)];
        catch me
            disp(me)
        end
    end
end

%%
for net_i = 1 : net_num
    fprintf('%s:\n', net_names{net_i})
    quality = [maxQualityList{net_i, :}];
    try
    psnr = reshape(quality(1, :), [], set_num)';
    ssim = reshape(quality(2, :), [], set_num)';
    catch ME
         disp(ME);
    end
    for ri = 1 : size(psnr, 1)
        fprintf('%s:\t', ImgSets{ri});
        for ci = 1 : size(psnr, 2)
            fprintf('%.2f/%.4f\t', psnr(ri, ci), ssim(ri, ci));
        end
        fprintf('\n');
    end
    fprintf('\n');
end
